from django.conf import settings
from django.forms import ModelForm

from tinymce.widgets import TinyMCE

from capabilities import formfield_callbacks

from t_ch.models import Technology
    
class TechnologyForm(ModelForm):
    formfield_callback = formfield_callbacks.html5
        
    def __init__(self, *args, **kwargs):
        super(TechnologyForm, self).__init__(*args, **kwargs)
        self.fields['name'].widget.attrs['autofocus'] = 'autofocus'
        self.fields['description'].widget = TinyMCE(attrs=settings.S_TE_TINYMCE_DEFAULT_ATTRS)

    class Meta:
        model = Technology
